/*Change new data*/

/*Esteban es un buen amigo*/

*proc printto log="&logdir.t01_enroll.log" new;
  run;
   
  ods listing close ;
   
  **************************************************************************
  Filename                 : T01_enroll
  Author                   : Pablo Orosco Joerger
  Date                     : July 05 , 2012
  Platform                 : Windows XP / SAS 9.2 / EG 4.3
  Protocol                 : 310505 Novartis
  Description              : Subject enrollment and evaluability
  Version                  : 1
  Modified by              : -
  Modification date        : -
  Modification description : -
  **************************************************************************  ;
   
  /*prepare summary of subject enrollment and evaluability layout tab  7.1.1.1*/
  proc tabulate data=i&studyno..i_page_2_3_4 out=enroll;
      class pop/  preloadfmt exclusive order=formatted;
      class treat;
      table pop={label=''}, treat={label=''}* n  / printmiss;
      format  pop pop.;
  run;
  proc sort data=enroll (keep=n pop treat) out=s_enroll1;
      by treat;
  run;
  proc transpose data=s_enroll1 out=t_enroll1
      prefix=p
      let
      name=source
      label=label;
      by treat;
      id pop;
      var n;
  run;
   
  quit;
   
  data t_enroll2 (drop=source);
      retain treat p1 p2 p0;
      set t_enroll1;
      enr=sum(p0,p1,p2);
   
      if enr = . then
          enr = 0;
      sisa=sum(p0,p1,p2);
   
      if sisa = . then
          sisa = 0;
      sesa=p0-p0;
   
      if sesa = . then
          sesa = 0;
      siitt=sum(p1,p2);
   
      if siitt = . then
          siitt = 0;
      seitt=p0;
   
      if seitt = . then
          seitt = 0;
      sipp=p2;
   
      if sipp = . then
          sipp = 0;
      sepp=(sum(p0,p1));
   
      if sepp = . then
          sepp = 0;
  run;
   
  proc sort data = t_enroll2 out = s_enroll2;
     by  enr sesa sisa seitt siitt sepp sipp;
  run;
   
  proc transpose data= s_enroll2 out= t_enroll3
     let
     name=source
     label=label;
     id treat;
     var enr sesa sisa seitt siitt sepp sipp;
  run;
   
  quit;
   
  data t_enroll3;
     set t_enroll3 (rename=('1'n = t1));
    source=upcase(source) ;
     con+10;
   
  run;
   
  proc sql;
     insert into t_enroll3 (con)
         values (5)
         values (19)
         values (39)
         values (59);
     create table t01_enroll as select
         source format $enroll. as factor,t1,con from t_enroll3 order by  con;
  quit;
  data t01_enroll ;
     set t01_enroll ;
  t1x = cats (t1);
  if factor=" " then do ;
  t1x = " ";
  end ;
  run;
   
  proc datasets library=work nolist;
     delete enroll s_enroll1 s_enroll2 t_enroll1 t_enroll2 t_enroll3;
  quit;
   
  proc printto log=log;
  run;
   
  